<?php
include('../../__global.php');
include(SERVER_ROOT_PATH.'/include/config/ml_guang_config.php');

class guang_tag extends ml_controller
{
    private $order;
    private $word;
    private $block;
    private $page;
    private $tgid;
    
    public function initParam()
    {
        $this->order = $this->input('order') == 'new' ? 'new' : 'hot';
        $this->word = $this->input('word');
        $this->page = $page = (int)$this->input('page' , '' , 1);
        $page = $page < 1 ? 1 : $page;
        $page = $page > 30 ? 1 : $page;
        $this->block = ($page-1)*3;
        
        $is = Tool_string::isUtf8($this->word);
        
        if(!$is) {
            $this->word = Tool_string::gb2utf($this->word);
        }
        
        $str = ml_tool_resid::getNickKey($this->word);
        
        $this->tgid = substr($str,4,strlen($str));
        echo $this->tgid;
        define('ML_GUANG_SEGMENT', $this->block);
        
    }
    public function checkParam()
    {
//        $aLmTag = ml_factory::load_standard_conf('lmTag');
//        if(!isset($aLmTag[$this->tgid]))
//            $this->redirect(ML_PAGE_GUANG);
    }
    public function main()
    {
        $page_type = 'tag_'.$this->order;
//        $oGuang = new ml_biz_guangData($page_type , $this->block , $this->tgid , $this->__visitor['uid']);
//        $aHtml = $oGuang->render_html_list();
        
        $oGuang = new ml_biz_pin_guang();
        $aHtml = $oGuang->output($page_type , $this->block , $this->tgid  , $this->__visitor['uid']);
        
        $aBlockCnf = array(
            0 => 1,
        );
        $data['pins'] = ml_tool_pinOutput::groupPinByColumn($aHtml , 4 , $aBlockCnf);
        $data['page_type'] = 'tag_'.$this->order;
        $data['hot_tag'] = ml_tool_getdata::mlJsonData('guanghottag','tagdata');
        $data['page_tag_id'] = $this->tgid;
        $data['noh1'] = true;//logo无h1标签
        $tag_name = $data['pagetitle'] = $data['hot_tag'][$this->tgid]['tag'];
        $data['righttag'] = ml_tool_getdata::mlJsonData('righttag'.$this->tgid,'righttag');
        $this->set_ria_version('201205311650');

        $total_block = $oGuang->get_total_block();
        $this->set_scope_var('$totalPage' , ceil($total_block / 3));
        $this->set_scope_var('$currentPage' , $this->page);
        $this->set_scope_var('$segment' , 0);
        $this->set_scope_var('$lastSegment' , $this->block == $total_block - 1 ? true : false);
        $this->set_scope_var('$page_type' , $this->order);
        $this->set_scope_var('$tag' , $this->tgid);

        $this->set_page_title($tag_name.'最热单品 - '.$tag_name.'的漂亮时尚潮流搭配');        
        $this->page_output('lm::guang_tag' , $data);
    }
    
}
new guang_tag();
?>